package com.github.common.extend.demo.config;

/**
 * @author X1993
 * @date 2022/10/24
 * @description
 */
public interface BaseEnum<T> {

    /**
     * 编号
     * @return
     */
    T getCode();

    /**
     * 描述
     * @return
     */
    String getDesc();

    static <C ,E extends BaseEnum<C>> E codeOf(E[] elements ,C code){
        if (code == null){
            return null;
        }
        for (E element : elements) {
            if (code.equals(element.getCode())){
                return element;
            }
        }
        return null;
    }

}
